package com.caishi.lkx.exam.records;

import com.caishi.lkx.exam.dto.ApiQuestionRecordsDtoItem;
import com.caishi.lkx.exam.ienum.type.QuestionType;
import com.caishi.lkx.exam.model.PaperRecordsModel;
import com.caishi.lkx.exam.records.dto.*;
import com.caishi.lkx.exam.vo.PaperResultVo;


import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

public interface RecordsService {

    /**
     * 用户答案是否正确
     *
     * @param collectId
     * @param answer
     * @return
     */
    boolean userAnswerIsRight(QuestionType type, String userId, String collectId, String rightAnswerBase64, Object answer);

    /**
     * 用户提交章节试题做题记录（单道题）
     * 如果用户已提交过答案进行覆盖，
     * 以前做错，现在作对后移除错题
     * 以前作对，现在做错加入错题
     *
     * @param userId       用户id
     * @param industryCode 行业code
     * @param examId       考试id
     * @param categoryId   科目id
     * @param qid          试题id
     * @param item         试题详情
     * @param right        是否正确
     * @param rightCount
     * @return -1 无操作 1 以前对 现在错 2以前错现在对 3新纪录对 4新纪录错 5移除错题
     */
    int userPushOneQuestionRecords(String userId, String industryCode, String examId, Long categoryId, String qid, NewRecordsDtoItem item, boolean right, int rightCount);


    void collectCountRecordsChange(String userId, String industryCode, String examId, Long categoryId, RecordsCollectType type, String id, RecordsCountRecordDto data);


    /**
     * 用户提交试卷
     *
     * @param userId
     * @param industryCode
     * @param examId
     * @param categoryId
     * @param recordsId
     * @param data
     * @return 考试结果
     */
    PaperResultVo userPushPaperRecords(String userId, String industryCode, String examId, Long categoryId, String recordsId, Map<String, ApiQuestionRecordsDtoItem> data, LocalDateTime endTime, Long seconds);

    PaperResultVo userPushPaperRecords(String industryCode, String examId, Long categoryId, PaperRecordsModel recordsModel, Map<String, ApiQuestionRecordsDtoItem> data, LocalDateTime endTime, Long seconds);

    /**
     * 保存用户试卷做题记录
     *
     * @param userId
     * @param industryCode
     * @param examId
     * @param categoryId
     * @param recordsId
     * @param content
     * @param seconds
     */
    void userSavePaperRecords(String userId, String industryCode, String examId, Long categoryId, String recordsId, Map<String, QuestionRecordsDtoItem> content, Long seconds, String lastId);

    /**
     * 保存集合错题集 生成最新错题数据
     *
     * @param userId
     * @param industryCode
     * @param examId
     * @param categoryId
     * @param type
     * @param id
     * @param errorData
     */
    void pushErrorBlockData(String userId, String industryCode, String examId, Long categoryId, RecordsCollectType type, String id, Map<String, NewRecordsDtoItem> errorData);


    /**
     * 保存集合收藏集合
     *
     * @param userId
     * @param industryCode
     * @param examId
     * @param categoryId
     * @param type
     * @param id
     * @param collectData
     */
    void pushCollectBlockData(String userId, String industryCode, String examId, Long categoryId, RecordsCollectType type, String id, Map<String, NewRecordsDtoItem> collectData, List<String> removeIds);

    /**
     * 设置最新的集合做题记录
     *
     * @param item         数据
     * @param id
     * @param userId
     * @param industryCode
     * @param examId
     * @param categoryId
     */
    void addCategoryNewCollectRecords(CategoryCollectRecordsDtoItem item, RecordsCollectType type, String id, String userId, String industryCode, String examId, Long categoryId);

    void removeCategoryNewCollectRecords(RecordsCollectType type, String id, String userId, String industryCode, String examId, Long categoryId);

    /**
     * 
     * @param userId
     * @param data
     * @param industryCode
     * @param examId
     * @param categoryId
     */
    void changeCategoryCountData(String userId, RecordsCountRecordDto data, String industryCode, String examId, Long categoryId);

    /**
     * 修改视频观看记录，顺便更新栏目观看统计，章节观看统计
     *
     * @param userId
     * @param data
     * @param industryCode
     * @param examId
     * @param categoryId
     * @param columnId
     * @param chapterId
     * @return
     */
    public VideoRecordsDto putVideoRecordsData(String userId, Map<String, VideoRecordsDtoItem> data , String industryCode, String examId, Long categoryId, String columnId, String chapterId);
}
